﻿using System;
using System.Collections;
using Evaluant.Uss;
using Evaluant.Uss.ObjectContext;
using Enumeration;

using NUnit.Framework;

namespace UseCases.EnumerationModel
{
	/// <summary>
	/// Description résumée de Program.
	/// </summary>
	/// 
	[TestFixture]
	public class Program
	{
		[Test]
		public void Main()
		{
			ObjectService pmf = 
				new ObjectService("UseCases.config", "EnumerationModel");
			pmf.AddAssembly(typeof(Person).Assembly);
			ObjectContext pm = pmf.CreateObjectContext();

			Person p = new Person();
			p.Name = "Dodsworth";
			p.Firstname = "John";
			p.Birthday = new DateTime(1970, 01, 10);

			p.Title = Titles.Mr;

			pm.InitializeRepository();
			pm.BeginTransaction();
			pm.Serialize(p);
			pm.CommitTransaction();

			pm.Clear();

			IList persons = pm.Load(typeof(Person), "[Name='Dodsworth']");

			Assert.AreEqual(1, persons.Count);
			Assert.AreEqual(Titles.Mr, ((Person)persons[0]).Title);
		}
	}
}
